This stack provides 3 XCMDs and 3 XFCNs that allow to fully master FileSharing : turn it on/off, test its state, share/unshare a folder, get and set its sharing privileges, get users and groups list.
ShareFolder, GetPrivileges and SetPrivileges can also be used with AppleShare.
FileSharingIsOn 1.0
DESCRIPTION
FileSharingIsOn allows to test is FileSharing is currently running or not. It requires System 7.
SYNTAX
FileSharingIsOn()
PARAMETERS
No parameter required.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
The XFCN returns true or false depending on current FileSharing state.
ERRORS
If an error occurs, FileSharingIsOn can return :
"Error : FileSharingIsOn requires System 7"
HISTORY
1.0 16/11/92
• First release
SetFileSharing 1.0
DESCRIPTION
SetFileSharing allows to start/stop FileSharing. It requires System 7.
SYNTAX
SetFileSharing <true|false>
PARAMETERS
<true|false> is a boolean. true starts FileSharing, false stops it.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
Think about testing the current FileSharing state with FileSharingIsOn before calling SetFileSharing, or you will get an error.
FileSharingIsOn will also be valuable to set a repeat loop after starting FileSharing, in order to be sure it is on (see script).
ERRORS
If an error occurs, SetFileSharing can return :
"Error : Couldn't locate File Sharing Extension"
"Error : File Sharing is off"
"Error : SetFileSharing requires System 7"
"Error : Missing or empty parameter"
"Error : Param is not a boolean"
HISTORY
1.0 16/11/92
• First release
ShareFolder 1.0
DESCRIPTION
ShareFolder allows to start ot stop sharing of a folder or volume.
SYNTAX
ShareFolder <folder path>,<true|false>
PARAMETERS
<folder path> is the full pathname of folder to share. As usual, a path of a folder alias can also be passed.
<true|false> is a boolean. true starts sharing, false stops it.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
Besure, using FileSharingIsOn, that FileSharing is on before using ShareFolder, and turn it on if necessary using SetFileSharing.
ERRORS
If an error occurs, ShareFolder can return :
"Error : Not a folder"
"Error : Volume not found"
"Error : Folder not found"
"Error : Missing or empty parameter"
"Error : Param #2 is not a boolean"
"Error : Too many shared folders"
"Error : Duplicate shared folder"
"Error : FileSharing is off"
"Error : This folder cannot be shared"
"Error : The folder contains a shared folder"
"Error : The folder is already shared"
"Error : FileSharing is off"
"Error : The folder is not shared"
HISTORY
1.0 16/11/92
• First release
GetPrivileges 1.0
DESCRIPTION
GetPrivileges return current privileges of a folder
SYNTAX
GetPrivileges(<folder path>)
PARAMETERS
<folder path> is the full pathname of folder to share. As usual, a path of a folder alias can also be passed.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
The XFCN return a full array (four lines of 4 items, line 4 having a 5th item) of informations :
WITH <access> = <name|*>,<see folders>,<see files>,<modify>
PARAMETERS
<folder path> is the full pathname of folder to share. As usual, a path of a folder alias can also be passed.
<owner access>, <group access> and <everyone access> define respectively access rights for owner, group and everyone. Note that <owner access> must be passed (even empty) if you need to change <group access>, and so on for <everyone access>.
Each access rights string is shaped as :
name|*,seeFolders,seeFiles,writeAllowed
name is the new name to set. You cannot change owner name of a folder of which you are not the current owner. Leaving this item empty allows to keep current name. Passing "*" allows to set <Any User> as owner or <None> as group. This item is simply skipped for Everyone access rights, since having no meaning.
seeFolders, seeFiles and writeAllowed are booleans. Leaving any of these items empty allows to keep current privileges.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
SetPrivileges can be used even if FileSharing is off or folder is not currently shared, but you must be owner of that folder to be allowed for any privilege change.
Note also that access parameter are shape-compatible with the result of GetPrivileges XFCN, which may help you.
Using examples:
• if you want to give full access to anybody, and reset owner and group to any, use :
SetPrivileges "HD:MyFolder:","*,true,true,true"¬
,"*,true,true,true","dummy,true,true,true"
• if you want to simply add write access to current group, use :
SetPrivileges "HD:MyFolder:","",",,,true"
ERRORS
If an error occurs, SetPrivileges can return :
"Error : Not a folder"
"Error : Volume not found"
"Error : Folder not found"
"Error : Unknown user name"
"Error : Unknown group name"
"Error : Missing or empty parameter"
"Error : Must be owner to set privileges"
"Error : Item #X of param #Y is not a boolean"
HISTORY
1.0 16/11/92
• First release
UsersAndGroupsList 1.0
DESCRIPTION
UsersAndGroupsList returns the list of defines users and groups. It requires System 7.
SYNTAX
UsersAndGroupsList()
PARAMETERS
No parameter is required.
Using "!", "?" and "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
The XFCN returns a two lines of items result, being respectively the list of users and the list of groups.
ERRORS
If an error occurs, UsersAndGroupsList can return :
Free for non-commercial use. Use in commercial software subjected to prior acknowledgement and licensing from the author, reachable at the following network addresses: